/*
 * =====================================================================================
 *
 *       Filename:  conerdetection.cpp
 *
 *    Description:  corner detection
 *
 *        Version:  1.0
 *        Created:  2009年07月15日 15时43分12秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ying Wang (WY), ywang@nlpr.ia.ac.cn
 *        Company:  Institute of Automation, Chinese Academy of Sciences
 *
 * =====================================================================================
 */

#include "point_detection.h"
#include "../imageio.h"
#include "../process.h"
#include <cstdlib>
#include <QtGui/QtGui>
int main(int argc, char* argv[])
{
	if(argc>1)
	{
		NCmatrix<double> g = gauss(5,5,3);
		std::cout<<g<<std::endl;
		QImage image(argv[1]);
		MultiMat matm = imtomat(image);
		NCpointVector corners = harris_corner(matm[0],g);
		int nump,alln = corners.size();
		if(argc>2)
		{
			nump = atoi(argv[2]);
			if(nump>alln)
				nump = alln;
		}
		else
		{
			nump = corners.size();
		}
		QPainter painter(&image);
		painter.setPen(QPen(Qt::blue,3,Qt::SolidLine,Qt::RoundCap,Qt::MiterJoin));

		NCpoint<int> p;
		for(int i=0;i<nump;i++)
		{
						p = corners[i];
			std::cout<<p.x()<<","<<p.y()<<std::endl;
			painter.drawRect(p.x()-3,p.y()-3,6,6);
		}
		painter.drawRect(40,40,40,40);
		image.save("result.jpg");
		
		
	}
	else
	{
		std::cout<<"wrong parameters"<<std::endl;
	}
}
